<!--
 *                        _oo0oo_
 *                       o8888888o
 *                       88" . "88
 *                       (| -_- |)
 *                       0\  =  /0
 *                     ___/`---'\___
 *                   .' \\|     |// '.
 *                  / \\|||  :  |||// \
 *                 / _||||| -:- |||||- \
 *                |   | \\\  - /// |   |
 *                | \_|  ''\---/''  |_/ |
 *                \  .-\__  '-'  ___/-. /
 *              ___'. .'  /--.--\  `. .'___
 *           ."" '<  `.___\_<|>_/___.' >' "".
 *          | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *          \  \ `_.   \_ __\ /__ _/   .-` /  /
 *      =====`-.____`.___ \_____/___.-`___.-'=====
 *                        `=---='
 * 
 * 
 *      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * 
 *            佛祖保佑       永不宕机     永无BUG
 * 
 * @Descripttion: 
 * @version: 
 * @Date: 2021-04-28 16:50:05
 * @LastEditors: huzhushan@126.com
 * @LastEditTime: 2021-04-28 16:50:41
 * @Author: huzhushan@126.com
 * @HomePage: https://huzhushan.gitee.io/vue3-element-admin
 * @Github: https://github.com/huzhushan/vue3-element-admin
 * @Donate: https://huzhushan.gitee.io/vue3-element-admin/donate/
 -->
<template>
  <el-form ref="data" :model="data" label-width="120px">
    <el-form-item label="服务名称">
      <el-input v-bind:model-value="data.serviceName"></el-input>
    </el-form-item>
    <el-form-item label="分支">
      <el-input v-bind:model-value="data.branchName"></el-input>
    </el-form-item>
    <el-form-item label="版本">
      <el-input v-bind:model-value="data.revisionList"></el-input>
    </el-form-item>
    <el-form-item label="运行时间">
      <el-input v-bind:model-value="data.runTime"></el-input>
    </el-form-item>
    <el-form-item label="运行类型">
      <el-input v-bind:model-value="runType()"></el-input>
    </el-form-item>
    <el-form-item label="用例集">
      <el-input
        :model-value="[data.testSet == 0 ? 'regression' : 'workflow']"
      ></el-input>
    </el-form-item>
    <el-form-item label="总的用例个数">
      <el-input v-bind:model-value="data.totalCase"></el-input>
    </el-form-item>
    <el-form-item label="通过的case数">
      <el-input v-bind:model-value="data.passCase"></el-input>
    </el-form-item>
    <el-form-item label="失败的case数">
      <el-input v-bind:model-value="data.failCase"></el-input>
    </el-form-item>
    <el-form-item label="失败的case详情">
      <el-input v-bind:model-value="data.failCaseList"></el-input>
    </el-form-item>
    <el-form-item label="通过率">
      <el-input v-bind:model-value="showPercentage"></el-input>
    </el-form-item>

    <el-form-item label-width="0">
      <el-button round type="primary" @click="back">返回</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts">
import { getIdDetail } from '@/api/auto'

export default {
  data() {
    return {
      data: {},
    }
  },
  created() {
    this.getDetail(this.$route.params.id)
  },
  //属性计算
  computed: {
    showPercentage: function() {
      return this.data.passingRate * 100 + '%'
    },
  },

  methods: {
    getDetail(parmas) {
      getIdDetail(parmas)
        .then(res => {
          console.log(res)
          this.data = res.data
        })
        .catch()
    },
    back() {
      this.$router.push('/auto/result')
    },
    runType() {
      if (this.data.runType === 0) {
        return 'staging CI'
      }
      if (this.data.runType === 1) {
        return 'timing trigger'
      }
      if (this.data.runType === 2) {
        return 'Regression'
      }
      if (this.data.runType === 3) {
        return 'spre-prd CI'
      }
      if (this.data.runType === 4) {
        return 'others'
      }
    },
  },
}
</script>
<style>
.el-form-item {
  text-align: center;
}
</style>
